home *** CD-ROM | disk | FTP | other *** search
/ Windows 6-Pak - Disc 4 / Windows 6-Pak (InfoMagic) (Disc 4) (1999).ISO / Text-Chat-Scripts / pp-320m.exe / pp300 / r-sound.mrc < prev    next >
Encoding:
Text File  |  1998-08-15  |  28.6 KB  |  622 lines

  1. ; -----------------------------------------------------
  2. ; Peace and Protection (by misspai)
  3. ; -----------------------------------------------------
  4. ; Sound and music support
  5. ; -----------------------------------------------------
  6. ; CTCP SOUND support
  7. ; -----------------------------------------------------
  8. ctcp 1:SOUND:*:_runsctcp $1-
  9. ctcp 1:MP3:*:if (.mp3 !isin $2-) _runsctcp SOUND $replace($2-,$chr(32),?) $+ .mp3 | elseif (.mp3 isin $2)  _runsctcp SOUND $2- | else  _runsctcp SOUND $replace($2-,$chr(32),?)
  10. ctcp 1:MP2:*:if (.mp2 !isin $2-) _runsctcp SOUND $replace($2-,$chr(32),?) $+ .mp2 | elseif (.mp2 isin $2)  _runsctcp SOUND $2- | else  _runsctcp SOUND $replace($2-,$chr(32),?)
  11. alias -l _runsctcp {
  12.   _timersinc 15 -soundfld. $+ $site
  13.   if (%-soundfld. [ $+ [ $site ] ] > 6) {
  14.     .ignore -tu20 $wildsite
  15.     disps %col.att $+ Ignoring CTCPs from %col.target $+ $wildsite $+  for 20 seconds to prevent lockup. (receiving too many SOUND requests.)
  16.   }
  17.   set %.ss.file $_ffprep($nopath($2)) | set %.+ss.play $true
  18.   if (%-soundfld. [ $+ [ $site ] ] > 3) {
  19.     set %.ss.color $remove(%col.dark,,,) | set %.ss.coloract $colour(act)
  20.     unset %.ss.dir | goto dispit
  21.   }
  22.   set %.ss.color %col.base | set %.ss.coloract $colour(high)
  23.   set %.ss.extn $_mapext($_rtok(1,46,%.ss.file))
  24.   if ((%.ss.extn == mp2) || (%.ss.extn == mp3)) set %.ss.extn mp
  25.   if ((%sounds.halt) && (($inwave) || ($inmidi))) set %.+ss.play $false | else set %.+ss.play %+accept. [ $+ [ %.ss.extn ] ]
  26.   if ((%.+ss.play) || (%+search.nonaccepts) || ($_ppcfg(Sound,AutoGet))) set %.ss.dir $_findsound(%.ss.file)
  27.   if (%.ss.dir == $null) { set %.ss.color $remove(%col.dark,,,) | set %.ss.coloract $colour(act) }
  28.   :dispit
  29.   if ($3 == $null) {
  30.     if ($chan == $null) {
  31.       if ($_isopen($nick)) echo %.ss.color -i2 $nick [Sound %col.file $2 ]
  32.       else echo %.ss.color -si2 [Sound %col.file $replace($2,?,$chr(32))  from $nick $+ ]]
  33.     }
  34.     else echo %.ss.color -i2 $chan [Sound %col.file $replace($2,?,$chr(32))  from $nick $+ ]]
  35.   }
  36.   else {
  37.     set %.ss.wild * $+ $gettok(%.ss.file,1,46) $+ *
  38.     if (%.ss.wild iswm $3-) unset %.ss.note
  39.     else set %.ss.note %col.misc $+ ( $+ $nopath($2) $+ )
  40.     if ($chan == $null) {
  41.       if ($query($nick) == $null) query $nick
  42.       echo %.ss.coloract -i2 $nick ñ $nick $3- $+  %.ss.note
  43.     }
  44.     else echo %.ss.coloract -i2 $chan ñ $nick $3- $+  %.ss.note
  45.   }
  46.   if ((%.ss.dir != $null) && (%.+ss.play)) {
  47.     if ((%_away.why == $null) || (%+accept.sounds.away)) splay %.ss.dir
  48.   }
  49.   elseif (%.ss.dir != $null) {
  50.     _dynpop.rot snd 8 $nopath(%.ss.dir)
  51.     _dynpop.rot spath 8 %.ss.dir
  52.   }
  53.   elseif (%-soundfld. [ $+ [ $site ] ] > 3) return
  54.   elseif (($_ppcfg(Sound,Autoget)) && ((%.ss.dir == $null) || ($_ppcfg(Sound,AutoGetRemember)))) {
  55.     unset %.auto.cmd
  56.     set %.auto.text $_s2p($strip($3-))
  57.     if (! isin %.auto.text) set %.auto.cmd $gettok($_rchop($pos(%.auto.text,!),%.auto.text),1,127)
  58.     elseif (Type isin %.auto.text) set %.auto.cmd $gettok($_rchop($calc(5 + $pos(%.auto.text,Type)),%.auto.text),1,127)
  59.     elseif (Type: isin %.auto.text) set %.auto.cmd $gettok($_rchop($calc(6 + $pos(%.auto.text,Type:)),%.auto.text),1,127)
  60.     elseif (toget isin %.auto.text) set %.auto.cmd $gettok($_rtok(2,127,$left($pos(%.auto.text,toget),%.auto.text)),1,127)
  61.     elseif (toleech isin %.auto.text) set %.auto.cmd $gettok($_rtok(2,127,$left($pos(%.auto.text,toleech),%.auto.text)),1,127)
  62.     elseif (forthis isin %.auto.text) set %.auto.cmd $gettok($_rtok(2,127,$left($pos(%.auto.text,forthis),%.auto.text)),1,127)
  63.     set %.auto.chr $left(%.auto.cmd,1)
  64.     if ((%.auto.chr isletter) || (%.auto.chr isnum) || ($len(%.auto.cmd) == 1) || ($count(%.auto.cmd,%.auto.chr) > 1)) unset %.auto.cmd
  65.     if ($_ppcfg(Sound,AutoGetRemember)) {
  66.       set %.auto.old $_ppcfg(AutoGet,$mask($fulladdress,3))
  67.       if (%.auto.old == off) halt
  68.       if (%.auto.cmd == $null) set %.auto.cmd %.auto.old
  69.       else _writecfg AutoGet $mask($fulladdress,3) %.auto.cmd
  70.     }
  71.     if (%.ss.dir != $null) halt
  72.     set %.auto.ext $_rtok(1,46,$2)
  73.     set %.auto.allow $replace($_ppcfg(Sound,AutoGetTypes),.,$chr(32))
  74.     set %.auto.num $_numtok(32,%.auto.allow)
  75.     :loop
  76.     if ($gettok(%.auto.allow,%.auto.num,32) iswm %.auto.ext) goto ok
  77.     if ($_vd(.auto.num) > 0) goto loop
  78.     halt
  79.     :ok
  80.     if ((%.auto.cmd == $null) && ($_ppcfg(Sound,AutoGetGuess))) set %.auto.cmd ! $+ $nick
  81.     if (%.auto.cmd != $null) {
  82.       if (($_ppcfg(Sound,AutoGetPrivate)) || ($chan == $null)) msg $nick %.auto.cmd $2
  83.       else msg $chan %.auto.cmd $2
  84.       _timersinc 15 -isaway. $+ $nick
  85.       _timersinc 300 -leechreq. $+ $fulladdress
  86.     }
  87.   }
  88.   halt
  89. }
  90. on 1:chat:SOUND *:{
  91.   set %.ss.file $_ffprep($nopath($remove($2,$chr(1))))
  92.   set %.ss.extn $_mapext($_rtok(1,46,%.ss.file))
  93.   if ((%.ss.extn == mp2) || (%.ss.extn == mp3)) set %.ss.extn mp
  94.   if (%+accept. [ $+ [ %.ss.extn ] ] != $true) unset %.ss.dir
  95.   else set %.ss.dir $_findsound(%.ss.file)
  96.   if (%.ss.dir != $null) if ((%_away.why == $null) || (%+accept.sounds.away)) splay %.ss.dir
  97. }
  98. ; -----------------------------------------------------
  99. ; Lets other people leech
  100. ; -----------------------------------------------------
  101. on 1:text:%leech.cmd.mask:*:if (($chan == $null) && ($_not($_isopen($nick)))) closemsg $nick | _doleech $1-
  102. on 1:chat:%leech.cmd.mask:_doleech $1-
  103. alias -l _doleech {
  104.   unset %.+halt
  105.   if (@ isin %leech.route) open @Leech
  106.   if (($_genflood(leech,-leech. [ $+ [ $site ] ] ,1)) || ($_genflood(leech,-recd.leech,1))) {
  107.     if (%.+halt) halt
  108.     if (%leech.route != none) disprs %leech.route %col.leech $+ [Leech] Request from %col.target $+ $nick $+  ignored- Flood protection " $+ %col.info1 $+ $1- $+ "
  109.     inc %_leech.ignored
  110.     _leechtitle
  111.     halt
  112.   }
  113.   if (%+leech.knownonly) {
  114.     if (($ulevel < 2) && ($nick !isnotify)) {
  115.       if (%leech.route != none) disprs %leech.route %col.leech $+ [Leech] Request from %col.target $+ $nick $+  ignored- User not in userlist or notify " $+ %col.info1 $+ $1- $+ "
  116.       inc %_leech.ignored
  117.       _leechtitle
  118.       halt
  119.     }
  120.   }
  121.   if (. isin $right($2,4)) set %.leech.file $2
  122.   else set %.leech.file $2-
  123.   set %.leech.ext $_rtok(1,46,%.leech.file)
  124.   if ((? isin %.leech.ext) || (* isin %.leech.ext) || (%.leech.ext == $null)) goto badext
  125.   set %.leech.allow $replace($_ppcfg(Sound,LeechTypes),.,$chr(32))
  126.   set %.leech.num $_numtok(32,%.leech.allow)
  127.   :loop
  128.   if ($gettok(%.leech.allow,%.leech.num,32) iswm %.leech.ext) goto ok
  129.   if ($_vd(.leech.num) > 0) goto loop
  130.   :badext
  131.   _qnotice $nick Sorry, you can't leech files of that type
  132.   if (%leech.route != none) disprs %leech.route %col.leech $+ [Leech] Request from %col.target $+ $nick $+  invalid- Unleechable file type " $+ %col.info1 $+ $1- $+ "
  133.   inc %_leech.invalid
  134.   _leechtitle
  135.   halt
  136.   :ok
  137.   if ($_numsend($nick) >= $_ppcfg(Sound,LeechMax)) {
  138.     _qnotice $nick Please wait until your current files finish before requesting another
  139.     if (%leech.route != none) disprs %leech.route %col.leech $+ [Leech] Request from %col.target $+ $nick $+  invalid- Max DCC sends reached " $+ %col.info1 $+ $1- $+ "
  140.     inc %_leech.invalid
  141.     _leechtitle
  142.     halt
  143.   }
  144.   set %.leech.filef $_findsound(%.leech.file)
  145.   if (%.leech.filef == $null) {
  146.     if (%leech.route != none) disprs %leech.route %col.leech $+ [Leech] Request from %col.target $+ $nick $+  invalid- No matching files " $+ %col.info1 $+ $1- $+ "
  147.     _qnotice $nick Sorry, I have no files matching %.leech.file
  148.     inc %_leech.invalid
  149.     _leechtitle
  150.     halt
  151.   }
  152.   _timersinc 15 -isaway. $+ $nick
  153.   if ($chr(32) isin %.leech.filef) .dcc send $nick " $+ %.leech.filef $+ "
  154.   else .dcc send $nick %.leech.filef
  155.   if (%leech.route != none) disprs %leech.route %col.leech $+ [Leech] Request from %col.target $+ $nick $+  filled- Sent %col.info2 $+ %.leech.filef $+  " $+ %col.info1 $+ $1- $+ "
  156.   inc %_leech.sent
  157.   _leechtitle
  158.   halt
  159. }
  160. alias -l _leechtitle {
  161.   if ($_not($_isopen(@Leech))) return
  162.   unset %.title
  163.   if (%_leech.sent > 0) set %.title %_leech.sent files sent,
  164.   if (%_leech.invalid > 0) set %.title %.title %_leech.invalid invalid requests,
  165.   if (%_leech.ignored > 0) set %.title %.title %_leech.ignored requests ignored,
  166.   titlebar @Leech $_lchop(1,%.title)
  167. }
  168. ; -----------------------------------------------------
  169. ; Basic sound commands
  170. ; -----------------------------------------------------
  171. alias wav if ($1 == $null) _dosnd Wave .wav *.wav $_wavedir | elseif (\ isin $1-) _dosnd Wave .wav *.wav $1- | else _dosnd Wave .wav * $+ $_ffprep($replace($1-,$chr(32),*)) $+ *.wav $_wavedir
  172. alias mid if ($1 == $null) _dosnd Midi .mid *.mid $_mididir | elseif (\ isin $1-) _dosnd Midi .mid *.mid $1- | else _dosnd Midi .mid * $+ $_ffprep($replace($1-,$chr(32),*)) $+ *.mid $_mididir
  173. alias mp if ($1 == $null) _dosnd MP2/MP3 .mp *.mp? $_mpdir | elseif (\ isin $1-) _dosnd MP2/MP3 .mp *.mp? $1- | else _dosnd MP2/MP3 .mp * $+ $_ffprep($replace($1-,$chr(32),*)) $+ *.mp? $_mpdir
  174. alias mp2 if ($1 == $null) _dosnd MP2 .mp *.mp2 $_mpdir | elseif (\ isin $1-) _dosnd MP2 .mp *.mp2 $1- | else _dosnd MP2 .mp * $+ $_ffprep($replace($1-,$chr(32),*)) $+ *.mp2 $_mpdir
  175. alias mp3 if ($1 == $null) _dosnd MP3 .mp *.mp3 $_mpdir | elseif (\ isin $1-) _dosnd MP3 .mp *.mp3 $1- | else _dosnd MP3 .mp * $+ $_ffprep($replace($1-,$chr(32),*)) $+ *.mp3 $_mpdir
  176. alias randwav wav *
  177. alias randmid mid *
  178. alias randmp mp *
  179. alias randmp2 mp2 *
  180. alias randmp3 mp3 *
  181. alias wavrand wav *
  182. alias midrand mid *
  183. alias mprand mp *
  184. alias mp2rand mp2 *
  185. alias mp3rand mp3 *
  186. alias rsound inc %_repnum | if ((%_repnum < 1) || (%_repnum > 10)) set %_repnum 1 | set %.ds.file %_last.sound | set %.ds.reas repeats.repeats again.plays yet again.here we go again.is it dead yet?.broken record it is.is addicted to.play it again, sam.tired of this song yet?.whooooooohoooooo! | set %.ds.play $_s2p($gettok(%.ds.reas,%_repnum,46)) | _finsound
  187. alias rrand rsound
  188. alias dsound {
  189.   if (%_last.sound == $null) return
  190.   _askyn _dsnd2 Delete $nopath(%_last.sound) $+ ?
  191. }
  192. alias cdesc {
  193.   set %.snd $1-
  194.   if (%.snd == $null) set %.snd %_last.sound
  195.   if (%.snd == $null) return
  196.   set %.snd $nopath(%.snd)
  197.   writeini $_ppdir $+ sound.ini description %.snd (none)
  198.   if ($_isopen(@Roulette)) rline @Roulette $sline(@Roulette,1).ln $_getexp($sline(@Roulette,1))
  199.   else dispa Description for %col.target $+ %.snd $+  cleared.
  200. }
  201. alias desc {
  202.   set %.snd $1-
  203.   if (%.snd == $null) set %.snd %_last.sound
  204.   if (%.snd == $null) return
  205.   set %.snd $nopath(%.snd)
  206.   set %.desc $_ppdesc(%.snd)
  207.   _pentry _findesc2 $+ $_s2p(%.desc) $_ New description for file %.snd $+ ?
  208. }
  209. alias _findesc2 {
  210.   if ($1 == $null) writeini $_ppdir $+ sound.ini description %.snd (none)
  211.   else writeini $_ppdir $+ sound.ini description %.snd $1-
  212.   if ($_isopen(@Roulette)) { set %_+roulcolor $true | rline @Roulette $sline(@Roulette,1).ln %col.info1 $+ $_s2f($1-) $+  $chr(160) $_getexp($sline(@Roulette,1)) }
  213. }
  214. alias _dsnd2 {
  215.   remove %_last.sound
  216.   if (%_last.soundline != $null) {
  217.     if (%_last.soundindex != $null) {
  218.       write -dl [ $+ [ $_i(%_last.soundline) ] ] %_last.soundindex
  219.       write -l1 %_last.soundindex $_j($lines(%_last.soundindex))
  220.     }
  221.     if (%_last.soundrate != $null) {
  222.       write -dl [ $+ [ $_i(%_last.soundline) ] ] %_last.soundrate
  223.       write -l1 %_last.soundrate $_j($lines(%_last.soundrate))
  224.     }
  225.   }
  226.   unset %_last.sound*
  227. }
  228. alias drand dsound
  229. alias z {
  230.   if ($1 == $null) _quickhelp /z
  231.   set %.ext $_mapext($remove($1,.))
  232.   if ($findtok(%soundfile.extmap2,%.ext,32) == $null) set %.mask *. $+ %.ext | else set %.mask *.*
  233.   set %.name %soundfile. [ $+ [ %.ext ] ]
  234.   if (%.name == $null) set %.name Custom Sound
  235.   set %.name $_s2f(%.name)
  236.   if ($2 == $null) _dosnd %.name . $+ %.ext %.mask $_ppcfg(Sound, [ [ %.ext ] $+ ] Dir)
  237.   elseif (\ isin $2-) _dosnd %.name . $+ %.ext %.mask $2-
  238.   else {
  239.     set %.mask * $+ $_ffprep($replace($2-,$chr(32),*)) $+ *.
  240.     _dosnd %.name . $+ %.ext $_maprev(%.ext,%.mask) $_ppcfg(Sound, [ [ %.ext ] $+ ] Dir)
  241.   }
  242. }
  243. alias zrand if ($1 == $null) _quickhelp /zrand | z $1 *
  244. alias randz zrand $1
  245. ; -----------------------------------------------------
  246. ; Continuous midis
  247. ; -----------------------------------------------------
  248. #continuemidi off
  249. on 1:midiend:{
  250.   unset %.ds.line %_last.soundindex %_last.soundrate
  251.   if (%+index.mid) {
  252.     set %_last.soundindex $_ppdir $+ mid-list.txt
  253.     :skipped
  254.     set %.ds.line $read -l0 %_last.soundindex
  255.     set %.ds.line $r(1,%.ds.line)
  256.     set %.ds.file $read -nl [ $+ [ %.ds.line ] ] %_last.soundindex
  257.     if (%+dynrate.mid) {
  258.       set %_last.soundrate $_ppdir $+ mid-rate.txt
  259.       set %.ds.rating $read -nl [ $+ [ %.ds.line ] ] %_last.soundrate
  260.       set %.ds.rating $gettok(%.ds.rating,1,32)
  261.       if (%.ds.rating > 0) {
  262.         set %.ds.skip $r(1,$_i(%.ds.rating))
  263.         if (%.ds.skip <= %.ds.rating) goto skipped
  264.       }
  265.     }
  266.   }
  267.   else set %.ds.file $_randfile(*.mid,$_mididir)
  268.   set %_last.soundline %.ds.line
  269.   _title $nopath(%.ds.file)
  270.   splay %.ds.file
  271. }
  272. #continuemidi end
  273. ; -----------------------------------------------------
  274. ; Playlist generation
  275. ; -----------------------------------------------------
  276. ; /playlist (type) (number) (mask)
  277. ; type is 1/2/3 or mp2/mp3 (1=mp2 + mp3) and defaults to 1
  278. ; number defaults to 40, mask to *
  279. ; type and number can be switched.
  280. alias playlist {
  281.   .timer918 off | .timer921 off
  282.   disps-div
  283.   disps Generating playlist...
  284.   set %.pl.max 40 | set %.pl.typen 1 | set %.pl.mask * | set %.pl.param $1-
  285.   if ($remove($1,mp) isin 1.2.3) { set %.pl.typen $remove($1,mp) | set %.pl.param $2- }
  286.   if ($gettok(%.pl.param,1,32) isnum) { set %.pl.max $gettok(%.pl.param,1,32) | set %.pl.param $gettok(%.pl.param,2-,32) }
  287.   if ($remove($gettok(%.pl.param,1,32),mp) isin 1.2.3) { set %.pl.typen $remove($gettok(%.pl.param,1,32),mp) | set %.pl.param $gettok(%.pl.param,2-,32) }
  288.   if (%.pl.param != $null) set %.pl.mask * $+ $_ffprep($gettok($replace(%.pl.param,$chr(32),*),1,46)) $+ *
  289.   set %.pl.type .mp?
  290.   if (%.pl.typen == 3) { set %.pl.type .mp3 | if ($_mp3exe == $null) _error MP3 player not defined! }
  291.   elseif (%.pl.typen == 2) { set %.pl.type .mp2 | if ($_mp2exe == $null) _error MP2 player not defined! }
  292.   else {
  293.     if ($_mp3exe == $null) {
  294.       if ($_mp2exe == $null) _error Neither MP2 nor MP3 player is defined!
  295.       disps MP3 player not defined- Only playlisting MP2s.
  296.       set %.pl.type .mp2
  297.     }
  298.     elseif ($_mp2exe == $null) { set %.pl.type .mp3 | disps MP2 player not defined- Only playlisting MP3s. }
  299.     elseif ($_mp2exe != $_mp3exe) { set %.pl.type .mp3 | disps MP2 and MP3 players differ- Only playlisting MP3s. }
  300.   }
  301.   set %.pl.mask %.pl.mask $+ %.pl.type
  302.   set %.pl.dir $_mpdir
  303.   if (%.pl.dir == $null) _error Directory for MP2/MP3s not defined!
  304.   if ((%.pl.mask == *.mp?) && (%+index.mp)) {
  305.     set %.pl.index $_ppdir $+ mp-list.txt
  306.     if ($_not($exists(%.pl.index))) _error Index file for MP2/MP3 files not created! (/mpindex to create)
  307.     set %.pl.num $read -l0 %.pl.index
  308.     if (%+dynrate.mp) {
  309.       set %.pl.ratefile $_ppdir $+ mp-rate.txt
  310.       if ($_not($exists(%.pl.ratefile))) _error Ratings file for MP2/MP3 files not created! (re-run indexer- /mpindex)
  311.     }
  312.     else unset %.pl.ratefile
  313.   }
  314.   else {
  315.     unset %.pl.index
  316.     set %.pl.num $_countfiles(%.pl.mask,%.pl.dir)
  317.     if (%.pl.num == 0) _error No files found matching  $+ %.pl.mask $+ 
  318.   }
  319.   _progress.1 Generating playlist... (files  $+ %.pl.mask $+ )
  320.   if (%.pl.type == .mp2) set %.pl.exe $_mp2exe
  321.   else set %.pl.exe $_mp3exe
  322.   if ($left(%.pl.mask,2) == *.) disps %.pl.num files found.
  323.   else disps %.pl.num files found (matching  $+ %.pl.mask $+ )
  324.   set %.pl.file $_ppdir $+ playlist
  325.   if ((maplay isin %.pl.exe) || (mp2win isin %.pl.exe)) set %.pl.file %.pl.file $+ .lst
  326.   else set %.pl.file %.pl.file $+ .m3u
  327.   if ($exists(%.pl.file)) .remove %.pl.file
  328.   set %.pl.do %.pl.max
  329.   if (%.pl.num <= $int($calc(%.pl.max / 4))) set %.pl.do %.pl.num
  330.   elseif (%.pl.num <= $int($calc(%.pl.max / 2))) set %.pl.do $int($calc(%.pl.max / 4))
  331.   elseif (%.pl.num <= $int($calc(%.pl.max + %.pl.max / 4))) set %.pl.do $int($calc(%.pl.num - %.pl.max / 4))
  332.   if (%.pl.do < %.pl.max) disps Only making list of %.pl.do files. (not enough found to pick %.pl.max randomly)
  333.   else disps Making list of %.pl.max files.
  334.   unset %.pl.did | set %.pl.cur 1
  335.   :file
  336.   set %.pl.n $r(1,%.pl.num)
  337.   if ($findtok(%.pl.did,%.pl.n,32) != $null) goto file
  338.   if (%.pl.index == $null) set %.pl.picked $_pickfile(%.pl.n,%.pl.mask,%.pl.dir)
  339.   else {
  340.     set %.pl.picked $read -nl [ $+ [ %.pl.n ] ] %.pl.index
  341.     if (%.pl.ratefile != $null) {
  342.       set %.pl.rating $read -nl [ $+ [ %.pl.n ] ] %.pl.ratefile
  343.       set %.pl.rating $gettok(%.pl.rating,1,32)
  344.       if (%.pl.rating > 0) {
  345.         set %.pl.skip $r(1,$calc(%.pl.rating + 2))
  346.         if (%.pl.skip <= $_i(%.pl.rating)) goto file
  347.       }
  348.     }
  349.   }
  350.   write %.pl.file %.pl.picked
  351.   set %.pl.perc $int($calc(%.pl.cur * 100 / %.pl.do))
  352.   _progress.2 %.pl.perc %.pl.cur $+ / $+ %.pl.do - %.pl.picked
  353.   set %.pl.did %.pl.did %.pl.n
  354.   if ($_vi(.pl.cur) <= %.pl.do) goto file
  355.   window -c @Progress
  356.   disps Playlist complete, running player.
  357.   if (%+minimize.mp) set %.to.min -n
  358.   else unset %.to.min
  359.   if ($chr(32) isin $mircdir) run %.to.min %.pl.exe " $+ $mircdir $+ %.pl.file $+ "
  360.   else run %.to.min %.pl.exe %.pl.file
  361.   disps-div
  362. }
  363. alias playlist2 playlist 2 $1-
  364. alias playlist3 playlist 3 $1-
  365. ; -----------------------------------------------------
  366. ; mIRC sound command
  367. ; replacements
  368. ; -----------------------------------------------------
  369. alias sound {
  370.   if ($1 == $null) _quickhelp /sound
  371.   if (($_isopen($1)) || (. !isin $1)) { if ($2 == $null) _quickhelp /sound | set %.ss.to $1 | set %.ss.file $2 | set %.ss.msg $3- }
  372.   else { if ((Status isin $active) || ($left($active,1) == @)) set %.ss.to $null | else set %.ss.to $active | set %.ss.file $1 | set %.ss.msg $2- }
  373.   if (\ !isin %.ss.file) set %.ss.file $_findsound($replace($replace(%.ss.file,▓,2),│,3))
  374.   else set %.ss.file $replace(%.ss.file,?,$chr(32))
  375.   if (%.ss.file == $null) _error Sound file not found
  376.   set %.ss.extn $_mapext($_rtok(1,46,%.ss.file))
  377.   if ((%.ss.extn == mp2) || (%.ss.extn == mp3)) set %.ss.extn mp
  378.   if (%+local. [ $+ [ %.ss.extn ] ] ) set %.ss.to $null
  379.   splay %.ss.file
  380.   if (%.ss.msg == $null) { set %.ss.show -> [Sound %col.file $nopath(%.ss.file) ] | set %.ss.color $remove(%col.dark,,,) }
  381.   else { set %.ss.show ñ $me %.ss.msg | set %.ss.color $colour(act) }
  382.   if (= isin %.ss.to) {
  383.     .msg %.ss.to SOUND $nopath($replace(%.ss.file,$chr(32),?)) %.ss.msg $+ 
  384.     echo %.ss.color -t2 %.ss.to %.ss.show
  385.   }
  386.   elseif (%.ss.to == $null) echo %.ss.color -si2 %.ss.show
  387.   else {
  388.     if (((%.+allwrap) || (%+sounds.ame)) && ($_ischan(%.ss.to))) {
  389.       set %.ss.to $_s2c($_getchans)
  390.       set %.ss.nums $_numtok(44,%.ss.to)
  391.       :sister
  392.       echo %.ss.color -i2 $gettok(%.ss.to,%.ss.nums,44) %.ss.show
  393.       if ($_vd(.ss.nums) > 0) goto sister
  394.     }
  395.     else {
  396.       if ($_isopen(%.ss.to)) echo %.ss.color -i2 %.ss.to %.ss.show
  397.       else echo %.ss.color -si2 -> %.ss.to %.ss.show
  398.     }
  399.     _qc %.ss.to SOUND $nopath($replace(%.ss.file,$chr(32),?)) %.ss.msg
  400.   }
  401. }
  402. alias splay {
  403.   if ($1 == $null) _quickhelp /splay
  404.   if ($1 == stop) { splay -wm stop | return }
  405.   if (\ !isin $1-) set %.to.play $_findsound($replace($replace($1-,▓,2),│,3))
  406.   else set %.to.play $1-
  407.   unset %.to.exe
  408.   set %.to.extn $_mapext($_rtok(1,46,%.to.play))
  409.   if (%.to.extn == mp2) {
  410.     set %.to.exe $_mp2exe
  411.     if (%.to.exe == $null) _error MP2 player not defined!
  412.   }
  413.   elseif (%.to.extn == mp3) {
  414.     set %.to.exe $_mp3exe
  415.     if (%.to.exe == $null) _error MP3 player not defined!
  416.   }
  417.   elseif (%.to.extn isin wav.mid) splay " $+ %.to.play $+ "
  418.   else {
  419.     set %.to.exe %.to.extn $+ Player
  420.     set %.to.exe $_ppcfg(Sound,%.to.exe)
  421.     if (%+minimize. [ $+ [ %.to.extn ] ] ) set %.to.min -n
  422.     else unset %.to.min
  423.     if ($chr(32) isin %.to.play) run %.to.min %.to.exe " $+ %.to.play $+ "
  424.     else run %.to.min %.to.exe %.to.play
  425.     unset %.to.exe
  426.   }
  427.   if (%.to.exe != $null) {
  428.     if ((maplay isin %.to.exe) || (mp2win isin %.to.exe)) set %.to.list playlist.lst
  429.     else set %.to.list playlist.m3u
  430.     write -c $_ppdir $+ %.to.list %.to.play
  431.     if (%+minimize.mp) set %.to.min -n
  432.     else unset %.to.min
  433.     if ($chr(32) isin $mircdir) run %.to.min %.to.exe " $+ $mircdir $+ $_ppsub $+ \ $+ %.to.list $+ "
  434.     else run %.to.min %.to.exe $_ppdir $+ %.to.list
  435.   }
  436.   _dynpop.rot snd 8 $nopath(%.to.play)
  437.   _dynpop.rot spath 8 %.to.play
  438.   _recfile2 %.to.play
  439.   set %_last.sound %.to.play
  440.   unset %_last.soundline
  441. }
  442. ; -----------------------------------------------------
  443. ; Internal sound commands and
  444. ; identifiers
  445. ; -----------------------------------------------------
  446. alias _findsound return $_randfile($_ffprep($1-),$_thedir($_rtok(1,46,$1-)))
  447. alias _dosnd {
  448.   unset %_repnum
  449.   if ((* isin $3-) && (($4 == $null) || ($4 == $chr(59)))) _error Directory for $1 $+ s not defined!
  450.   set %.ds.play %soundact [ $+ [ $2 ] ]
  451.   if (%.ds.play == $null) set %.ds.play plays
  452.   else set %.ds.play $_s2p(%.ds.play)
  453.   unset %.ds.line %_last.soundindex %_last.soundrate
  454.   if ($gettok($3,1,46) != *) {
  455.     if ($left($3,4) == ***.) {
  456.       set %.ds.play randomly $+ %.ds.play
  457.       if (%+index [ $+ [ $2 ] ] ) {
  458.         set %_last.soundindex $_ppdir $+ $remove($2,.) $+ -list.txt
  459.         if ($exists(%_last.soundindex)) {
  460.           :skipped
  461.           set %.ds.line $read -l0 %_last.soundindex
  462.           set %.ds.line $calc(($ticks + $r(1,%.ds.line)) % %.ds.line + 1)
  463.           set %.ds.file $read -nl [ $+ [ %.ds.line ] ] %_last.soundindex
  464.         }
  465.         else {
  466.           if ($2 isin .mp.wav.mid) _error Index file for $1 files not created! (/ $+ $remove($2,.) $+ index to create)
  467.           else _error Index file for $1 files not created! (/zindex remove($2,.) to create)
  468.         }
  469.         if (%+dynrate [ $+ [ $2 ] ] ) {
  470.           set %_last.soundrate $_ppdir $+ $remove($2,.) $+ -rate.txt
  471.           if ($exists(%_last.soundrate)) set %.ds.rating $read -nl [ $+ [ %.ds.line ] ] %_last.soundrate
  472.           else _error Ratings file for $1 files not created! (re-run indexer)
  473.           set %.ds.rating $gettok(%.ds.rating,1,32)
  474.           if (%.ds.rating > 0) {
  475.             set %.ds.skip $r(1,$_i(%.ds.rating))
  476.             if (%.ds.skip <= %.ds.rating) goto skipped
  477.             .timer921 1 60 _keeprate %.ds.line %_last.soundrate
  478.           }
  479.           if (%_killrating != $null) {
  480.             set %.ds.rating $read -nl [ $+ [ %_killrating ] ] %_last.soundrate
  481.             if (%.ds.rating != $null) write -l [ $+ [ $_i(%_killrating) ] ] %_last.soundrate $_i($gettok(%.ds.rating,1,32))
  482.           }
  483.           set %_killrating %.ds.line
  484.           .timer918 1 15 unset %_killrating
  485.         }
  486.       }
  487.       else set %.ds.file $_randfile($3,$4-)
  488.     }
  489.     elseif (* !isin $3-) {
  490.       set %.ds.file $3-
  491.       if ($_not($exists($3-))) _error Sound file  $+ $3- $+  not found
  492.     }
  493.     else {
  494.       set %.ds.do $3 | unset %.cf.win %.+cf.keep
  495.       if ($left($3,2) == *?) { set %.ds.do * $+ $_rchop(2,%.ds.do) | set %.cf.win @Roulette | set %.+cf.keep $true | window -c @Roulette | open @Roulette }
  496.       elseif ($left($3,2) == *!) set %.ds.do * $+ $_rchop(2,%.ds.do)
  497.       elseif (%+roulette [ $+ [ $2 ] ] ) { set %.cf.win @Roulette | window -c @Roulette | open @Roulette }
  498.       set %.ds.file $_randfile(%.ds.do,$4-)
  499.       if (%.ds.file == @) {
  500.         titlebar @Roulette selection for sound files ( $+ $line(@Roulette,0) matches)
  501.         iline @Roulette 1 - Double-click on a file to play it - (right-click for other options)
  502.         if (%+roulette.retain) iline @Roulette 2 - Window will stay open on play (double-click here to toggle) -
  503.         else iline @Roulette 2 - Window will close on play (double-click here to toggle) -
  504.         iline @Roulette 3 $chr(160)
  505.         iline -s @Roulette 4 - Double-click here to select one randomly -
  506.         iline @Roulette 5 - Double-click here to playlist all files -
  507.         iline @Roulette 6 $chr(160)
  508.         window -arb @Roulette
  509.         halt
  510.       }
  511.     }
  512.     if (%.ds.file == $null) { window -c @Roulette | _error No $1 files found matching  $+ $3 $+  }
  513.   }
  514.   else {
  515.     .timer918 off | .timer921 off
  516.     set %.ds.where $gettok($4-,1,59)
  517.     if ($right(%.ds.where,1) != \) set %.ds.where %.ds.where $+ \
  518.     set %.ds.where %.ds.where $+ $3
  519.     set %.ds.query '' $+ $1 to play?''
  520.     _timer924off
  521.     set %.ds.file [ $dir= [ $+ [ %.ds.query ] ] %.ds.where ]
  522.     _timer924on
  523.     if (%.ds.file == $null) halt
  524.   }
  525.   if (~ isin %.ds.file) set %.ds.file $findfile($nofile(%.ds.file),$nopath(%.ds.file),1)
  526.   unset %.ds.act
  527.   set %.ds.descs %+desc [ $+ [ $2 ] ]
  528.   if (%+askact [ $+ [ $2 ] ] ) _pentry _finsound Action to go with $nopath(%.ds.file) $+ ?( $+ %col.custdark $+ Enter for %col.custdark $+ default.)
  529.   _finsound %.ds.act
  530. }
  531. alias _finsound {
  532.   if ($1 == $null) {
  533.     set %.gm.desc $_ppdesc($nopath(%.ds.file))
  534.     if ((%.gm.desc == $null) && (%.ds.descs))  _pentry _findesc Description for file %.ds.file $+ ?( $+ %col.custdark $+ Enter for %col.custdark $+ none; You won't be asked again for this file.)
  535.     sound $replace(%.ds.file,$chr(32),?) $_soundmsg(%.ds.play,%.ds.descs, %.ds.file)
  536.   }
  537.   else sound $replace(%.ds.file,$chr(32),?) $1-
  538.   set %_last.soundline %.ds.line
  539. }
  540. alias _findesc {
  541.   if ($1 == $null) writeini $_ppdir $+ sound.ini description $nopath(%.ds.file) (none)
  542.   else writeini $_ppdir $+ sound.ini description $nopath(%.ds.file) $1-
  543.   sound $replace(%.ds.file,$chr(32),?) $_soundmsg(%.ds.play, %+desc [ $+ [ $2 ] ] , %.ds.file)
  544.   set %_last.soundline %.ds.line
  545. }
  546. alias _keeprate {
  547.   set %.kr.rating $read -nl [ $+ [ $1 ] ] $2-
  548.   if (%.kr.rating == $null) halt
  549.   if (K isin %.kr.rating) write -l [ $+ [ $_i($1) ] ] $2- 0
  550.   else write -l [ $+ [ $_i($1) ] ] $2- %.kr.rating K
  551. }
  552. ; _soundindex MP MP2/3 *.mp? $_mpdir
  553. alias -l _soundindex {
  554.   set %.si.ini $_ppdir $+ $1 $+ -list.txt
  555.   if (%+dynrate. [ $+ [ $1 ] ] ) {
  556.     set %.si.inirate $_ppdir $+ $1 $+ -rate.txt
  557.     if ($exists(%.si.inirate)) {
  558.       set %.si.oldrate $_ppdir $+ oldrate.dat
  559.       if ($exists(%.si.oldrate)) .remove %.si.oldrate
  560.       set %.si.savet $_j($lines(%.si.ini))
  561.       set %.si.savec 1
  562.       _progress.1 Saving and indexing old ratings... ( $+ %.si.savet ratings)
  563.       :loopsv
  564.       set %.si.oldf $read -nl [ $+ [ %.si.savec ] ] %.si.ini
  565.       if ($_vi(.si.mup) > 5) {
  566.         set %.si.perc $int($calc(%.si.savec * 100 / %.si.savet))
  567.         _progress.2 %.si.perc %.si.savec $+ / $+ %.si.savet - %.si.oldf
  568.         unset %.si.mup
  569.       }
  570.       set %.si.oldr $read -nl [ $+ [ %.si.savec ] ] %.si.inirate
  571.       write %.si.oldrate $_ffprep(%.si.oldf) %.si.oldr
  572.       write %.si.oldrate $_ffprep($nopath(%.si.oldf)) %.si.oldr
  573.       if ($_vi(.si.savec) <= %.si.savet) goto loopsv
  574.       window -c @Progress
  575.     }
  576.     else unset %.si.oldrate
  577.   }
  578.   else unset %.si.inirate
  579.   window -nlh @IndexTemp
  580.   set %.cf.win @IndexTemp
  581.   set %.si.total $_countfiles($3,$4-)
  582.   if (%.si.total == 0) _error No files found to index!
  583.   _progress.1 Generating $2 index... ( $+ %.si.total files)
  584.   if ($exists(%.si.ini)) .remove %.si.ini
  585.   iline @IndexTemp 1 %.si.total
  586.   .savebuf @IndexTemp %.si.ini
  587.   if (%.si.inirate != $null) {
  588.     dline @IndexTemp 1
  589.     set %.si.cur 1
  590.     :loop
  591.     set %.si.file $line(@IndexTemp,%.si.cur)
  592.     if ($_vi(.si.mup) > 5) {
  593.       set %.si.perc $int($calc(%.si.cur * 100 / %.si.total))
  594.       _progress.2 %.si.perc %.si.cur $+ / $+ %.si.total - %.si.file
  595.       unset %.si.mup
  596.     }
  597.     if (%.si.oldrate != $null) {
  598.       set %.si.prevrate $read -ns [ $+ [ $_ffprep(%.si.file) ] ] %.si.oldrate
  599.       if (%.si.prevrate == $null) set %.si.prevrate $read -ns [ $+ [ $_ffprep($nopath(%.si.file)) ] ] %.si.oldrate
  600.       if (%.si.prevrate == $null) rline @IndexTemp %.si.cur 0
  601.       else rline @IndexTemp %.si.cur %.si.prevrate
  602.     }
  603.     else rline @IndexTemp %.si.cur 0
  604.     if ($_vi(.si.cur) <= %.si.total) goto loop
  605.     if ($exists(%.si.inirate)) .remove %.si.inirate
  606.     iline @IndexTemp 1 %.si.total
  607.     .savebuf @IndexTemp %.si.inirate
  608.     if (%.si.oldrate != $null) if ($exists(%.si.oldrate)) .remove %.si.oldrate
  609.   }
  610.   window -c @IndexTemp
  611.   _progress.2 100 Done!
  612. }
  613. alias mpindex _soundindex MP MP2/3 $_maprev(mp2,*.) $+ ; $+ $_maprev(mp3,*.) $_mpdir
  614. alias midindex _soundindex MID Midi $_maprev(mid,*.) $_mididir
  615. alias wavindex _soundindex WAV Wave $_maprev(wav,*.) $_wavedir
  616. alias zindex {
  617.   if ($1 == $null) _quickhelp /zindex
  618.   set %.ext $_mapext($remove($1,.))
  619.   set %.name %soundfile. [ $+ [ %.ext ] ] 
  620.   _soundindex %.ext $_s2f(%.name) $_maprev(%.ext,*.) $_ppcfg(Sound, [ [ %.ext ] $+ ] Dir)
  621. }
  622.